package com.flainsky.nirvanaplayer.adpters;

import java.util.List;

import com.flainsky.nirvanaplayer.R;
import com.flainsky.nirvanaplayer.lib.objects.Movie;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class RankingAdapter extends BaseAdapter {

	private Context mContext;
	private List<Movie> mList;
	
	public RankingAdapter(Context context,List<Movie> list)
	{
		mContext = context;
		mList = list;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return mList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if(convertView == null)
		{
			LayoutInflater inflater=LayoutInflater.from(mContext);
			convertView  = inflater.inflate(R.layout.main_ranking_item, null);
			TextView tv = (TextView)convertView.findViewById(R.id.tv);
			tv.setText(String.valueOf(position+1)+"  "+mList.get(position).mTitle);
		}
		else
		{
			((TextView)convertView.findViewById(R.id.tv)).setText(String.valueOf(position+1)+"  "+mList.get(position).mTitle);
		}
		return convertView;
	}

}
